#include <iostream>
#include <math.h>
#include <sstream>
#include <vector>
#include <string>
#include<fstream>
using namespace std;
class Mat {
public:
  Mat(int x,int y, double (*A)[10000]) {
     rows = x;
     cols = y;
     if (x<y - 1){
      cout << "Not enough" << endl;
     }
    for (int i = 0; i<x; i++) {
      for(int j=0;j<y;j++){
	data[i][j] =  A[i][j];
      }
    }
  }
  int matcols();
  int matrows();
  void gauss();
  void change(int x);
  void result();
private:
  int rows;
  int cols;
  double data[10000][10000];
};


int Mat::matcols() {
  return cols;
}

int Mat::matrows() {
  return rows;
}
void Mat::gauss() {
  double m = 0;
  double flag = 0;
  for (int i = 0; i<rows; i++) {
    change(i);
    if (data[i][i] != 0) {
      for (int j = i + 1; j<rows; j++) {
	//m = 1;
	if (data[j][i] == 0)
	  continue;
	m = abs(1.0 * data[i][i] / data[j][i]);

	if ((data[j][i] > 0 && data[i][i] > 0) || (data[j][i] < 0 && data[i][i] < 0)) {
	  flag = 1;
	}
	else
	  {
	    flag = -1;
	  }
	for (int k = i; k<cols; k++) {
	  data[j][k] = data[j][k] * m - flag*data[i][k];
	}
      }
    }
  }
  
}

void Mat::change(int x) {
  double temp = 0;
  double max = abs(data[x][x]);
  int loc = x;
  for (int i = x; i < rows; i++) {
    if (abs(data[i][x]) > max) {
      max = abs(data[i][x]);
      loc = i;
    }
  }
  if (x != loc) {
    for (int i = x; i < cols; i++) {
      temp = data[x][i];
      data[x][i] = data[loc][i];
      data[loc][i] = temp;
    }
  }
}

void Mat::result() {
  double ans[10000] = {0};
  double sum = 0;

  for (int i = 1; i < cols; i++) {
    sum = data[cols - 1- i][cols -1 ];
    for (int j = 1; j < i; j++) {
      sum -= ans[cols - j] * data[rows - i][rows - j];
    }
    ans[cols - i] = sum / data[cols-1 - i][cols - 1 - i];
  }
  for (int i = 1; i < cols; i++) {
    cout << ans[i] <<endl;
  }
}
int main(int argc, char** argv) {
  int n,max;
  double A[10000][10000];
  int  p;
  int q;
  double z;
  string line;
  ifstream infile("spmat.csv");
  max=0;
  char s1;
  char s2;

 int j=0;
 while(getline(infile, line)){

 istringstream Istrstream(line);
 
 Istrstream >> p >> s1>> q >> s2 >> z;
 if(max<p){
   max=p;
 }
 A[p-1][q-1]=z;
 }
 infile.close();
 n=max;
 string line1;
ifstream infile1("rhs.csv",ios::in);
 int i=0;
 double b;
 while(getline(infile1,line1)){
   istringstream Istrstream1(line1);
   Istrstream1 >> b;
     A[i][n]=b;
     i++;
     }
 Mat aa(n,n+1,A);
 aa.gauss();
 aa.result();
  return 0;
}
